﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Transactions;

namespace Chinaer.Core.Helper
{
    /// <summary>
    /// 事务相关类
    /// </summary>
    public class TransactionHelper
    {
        private static TransactionHelper _instance = null;
        public static TransactionHelper Instance
        {
            get
            {
                if (_instance == null)
                {
                    _instance = new TransactionHelper();
                }
                return _instance;
            }
        }

        public TransactionHelper() { }
        /// <summary>
        /// 返回指定的TransactionScope
        /// </summary>
        /// <returns></returns>
        public TransactionScope BeginTransaction()
        {
            return new TransactionScope(TransactionScopeOption.Required, new TimeSpan(0, 2, 0));
        }

        public void CommintTransaction(TransactionScope transaction)
        {
            using (transaction)
            {
                transaction.Complete();
            }
        }


    }
}
